package day5;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class Arr2 {
    public static void main(String[] args) {
        int []a1=new int[10];
        Scanner in=new Scanner(System.in);
        //循环赋值
        System.out.print("请输入数组的值：");
        for (int i = 0; i < a1.length; i++) {
            a1[i]=in.nextInt();
        }
        System.out.println("您输入的值是：");
        for (int i = 0; i < a1.length; i++) {
            System.out.print(a1[i]+" ");
        }
        //累加求和
        int sum =0;
        for (int i = 0; i < a1.length; i++) {
           sum+=a1[i];
        }
        int avg=sum/a1.length;
        System.out.println("平均是:"+avg);
        //越界
//        System.out.println(a1[10]);
//        System.out.println(a1[-2]);

    }
}
